/*

Author   : chaos

FileName : fun_sort.cpp

Date     : 09/08/17 10:53:49

*/
#include <iostream>
using namespace std;

void buble_asc(int *,int);
void prn_arr(int *,int);

int main(void)
{
    int array[5] ={3,5,2,4,3};

    cout << "Original arr=";
    prn_arr(array,5);
    cout << endl << endl;

    buble_asc(array,5);

    cout << endl << " Sort arr = ";
    prn_arr(array , 5);
    cout << endl;

    return 0;
}

void buble_asc(int *arr, int size){
    int temp;

    for (int i = 1; i < size; i++) {

        for (int j = 0; j < (size -i); j++) {
            if(arr[j] > arr[j+1]){
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1]= temp;
            }
            cout << "sort [" << i << "][" << j <<"]=";
            prn_arr(arr,5);
            cout << endl;
        }

        cout << "sort[" << i << "] = ";
        prn_arr(arr,5);
        cout << endl;

    }
}

void prn_arr(int *arr, int size){

    for (int i = 0; i < size; i++) {
        cout << arr[i] << "\t";
    }

}
